import React from 'react';
import { render } from 'react-dom';

import { createStore, applyMiddleware, compose } from 'redux';
import { Provider } from 'react-redux';

import createHistory from 'history/createBrowserHistory';
import { Route } from 'react-router-dom';

import { ConnectedRouter, routerMiddleware } from 'react-router-redux';

import thunk from 'redux-thunk';
import { Meteor } from 'meteor/meteor';

import rootReducer from '../imports/reducers';
import App from '../imports/ui/App';



const history = createHistory();

console.log(process.env.NODE_ENV);
console.log(process.env.API_URL);

// Build the middleware for intercepting and dispatching navigation actions
const middleware = [thunk, routerMiddleware(history)];

/* eslint-disable no-underscore-dangle */
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
  rootReducer, /* preloadedState */
  composeEnhancers(applyMiddleware(...middleware)),
);
/* eslint-enable */


Meteor.startup(() => {
  
  render(
 
     
    <Provider store={store}>
      <ConnectedRouter history={history}>
        <Route path="/" component={App} />
      </ConnectedRouter>
    </Provider>,

    document.getElementById('app'),
  );

});
